package com.java.thread.sample_02;
/**
 * NEW_至今尚未启动的线程!
 * RUNNABLE_正在 Java虚拟机中执行的线程!
 * TIMED_WAITING_具有指定等待时间的某一线程!
 * WAITING_无限期地等待另一个线程来执行某一特定操作的线程!
 * BLOCKED_受阻塞并等待某个监视器锁的线程!
 * TERMINATED_已终止的线程!
 */
public class ThreadStateTest implements Runnable{
	private boolean flag = true;
	public void run(){  
		try {
			Thread.sleep(5000);
			if(flag){
				flag = false;
				synchronized(this){
					this.wait();
				}
			}else{
				synchronized(this){
					this.notifyAll();
					Thread.sleep(4000);
				}
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	} 
}
